package com.museum.controller;

import com.alibaba.fastjson.JSONObject;
import com.museum.base.BaseApiService;
import com.museum.base.BaseResponse;
import com.museum.controller.APi.CirculatingAPI;
import com.museum.entity.DTO.CirculatingCol;
import com.museum.entity.message.Circulating;
import com.museum.service.impl.CirculatingServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/clue")
public class CirculatingController extends BaseApiService<JSONObject> implements CirculatingAPI {
    @Autowired
    private CirculatingServiceImpl service;

    @Override
    public BaseResponse<JSONObject> addCirculating(Circulating circulating, HttpServletRequest request) {
        int result = service.addCirculating(circulating,request);
        if(result>0){
            return setResultSuccess("添加成功");
        }else{
            return setResultError("添加失败");
        }
    }



    @Override
    public BaseResponse<JSONObject> getAllCirculatingByPage(long current, long limit, CirculatingCol col) {
        JSONObject json = service.getAllCirculatingByPage(current,limit,col);
        return setResultSuccess(json);
    }

    @Override
    public BaseResponse<JSONObject> deleteCirculatingById(Integer id) {
        int result = service.deleteCirculatingById(id);
        if(result>0){
            return setResultSuccess("删除成功");
        }else{
            return setResultError("删除失败");
        }
    }
}
